<template>
    <div>
        <div class="a-select-city-position">
            <div class="title-txt">定位城市</div>
            <div class="current-city">
                <span class="all_bg icon"></span>
                <span class="js-selected-city txt">{{selected.cityname}}</span>
            </div>
            <div class="scroll-tag">
                <a :href="'#'+key" v-for="(obj,key) in citysData">{{key}}</a>
            </div>
            <div class="native-scroll">
                <div>
                    <div class="city-place">
                        <div id="#"  class="title-txt">热门城市</div>
                        <ul class="js-select-city-list hot-city clearfix">
                            <li v-for="v in hotCity"><a @click="linkToSelectedCity(v)" href="javascript:void(0)">{{v.cityname}}</a></li>
                        </ul>
                    </div>
                    <div class="js-select-city-list cityList">
                        <dl v-for="(obj,key) in citysData">
                            <dt><a :id="key" href="javascript:void(0)">{{key}}</a></dt>
                            <dd v-for="v in obj"><a @click="linkToSelectedCity(v)" href="javascript:void(0)">{{v.cityname}}</a></dd>
                        </dl>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "gpsCitys",
        methods:{
            linkToSelectedCity(v){
                this.$store.commit('setSelectedCity',v);
                this.$router.replace('/');
            }
        },
        computed:{
            //citysJSON.js
            hotCity(){
                return this.$store.getters.getCitysJSON.hotCity;
            },
            citysData(){
                return this.$store.getters.getCitysJSON.citysData;
            },
            selected(){
                return this.$store.getters.getSelectedCity;
            }
        }
    }
</script>

<style scoped>

</style>
